import {
     ExecutorContext,
     Reference,
     Realm,
     JSObject,
     JSNumber,
     JSBoolean,
     JSString,
     JSUndefined,
     JSNull,
     JSSymbol,
     CompletionRecord,
     EnvironmentRecord,
     ObjectEnvironmentRecord,
     ExecutionContext
} from "./runtime.js"

export class Evaluator {

     constructor() {
          this.realm = new Realm();
          this.globalObject = new JSObject();
          this.globalObject.set("log", new JSObject());
          this.globalObject.get("log").call = args => {
               console.log(args);
          }
          this.ecs = [new ExecutorContext(
               this.realm, 
               new ObjectEnvironmentRecord(this.globalObject),
               new ObjectEnvironmentRecord(this.globalIbject)
          )];
     }

     evaluator(node) {
          let globalEC = this.ecs[0];
          let newEC = new ExecutionContext(
               this.realm,
               new EnvironmentRecord(globalEC.lexicalEnvironment),
               new EnvironmentRecord(globalEC.lexicalEnvironment)

          );
          this.ecs.push(newEC);
          let result = this.evaluate(node);
          this.ecs.pop();
          return result;
     }


}


